#ifndef LOG_H_INCLUDED
#define LOG_H_INCLUDED
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <pthread.h>
/** @file */

/** FILE representing the open log file.  Defaulting to stderr, this file is defined by log_init() in main() when the "-ologfile=" option is used */
extern std::ostream *_log;
#define LOG (*_log) << currentTS() << " THREAD-" << pthread_self() << " " << __FILE__ << ":" << __LINE__ << ":" << __func__ << " "
#define ENDL std::endl;
#define LOG_ERR (*_log) << "ERROR: " << " THREAD-" << pthread_self() << " " << __FILE__ << ":" << __LINE__ << ":" << __func__ << " "

const char *currentTS();
void log_init(const char *filename);
void log_finish();



/**
 * initialize the log.  If "stdout" or "stderr" are used, the existing streams will be returned.
 * @return a pointer to the newly-opened log file, or stdout or stderr if those strings are used
 * @param filename name of file to use
 * @param verbose print a message to show the filename being opened
 */
//FILE *log_init(const char *filename, int verbose);

/** close the log file */
//void log_finish(FILE * f);

#endif
